//
//  ViewController.m
//  滤镜
//
//  Created by dllo on 15/11/17.
//  Copyright © 2015年 张树林. All rights reserved.
//

#import "ViewController.h"

#define SCREEN_WIDTH self.view.bounds.size.width
#define SCREEN_HEIGHT self.view.bounds.size.height

@interface ViewController () <UIPickerViewDataSource, UIPickerViewDelegate>

{
    NSMutableArray *_pickerData;
    UIPickerView *_pickerView;
    UIImageView *_imageView;
    UIImage *_originImage;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showPicker)];
    tapGesture.numberOfTapsRequired = 1;
    [self.view addGestureRecognizer:tapGesture];
    
    _originImage = [[UIImage alloc] init];
    _originImage = [UIImage imageNamed:@"pic.jpg"];
    
    //imageView
    _imageView = [[UIImageView alloc] initWithImage:_originImage];
    _imageView.frame = self.view.bounds;
    _imageView.center = self.view.center;
    [self.view addSubview:_imageView];
    
    _pickerData = [[NSMutableArray alloc] initWithObjects:
                   @"OriginImage",
                   @"CIPhotoEffectMono",
                   @"CIPhotoEffectChrome",
                   @"CIPhotoEffectFade",
                   @"CIPhotoEffectInstant",
                   @"CIPhotoEffectNoir",
                   @"CIPhotoEffectProcess",
                   @"CIPhotoEffectTonal",
                   @"CIPhotoEffectTransfer",
                   @"CISRGBToneCurveToLinear",
                   nil];
    
    int pickerHeight = 200;
    _pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, pickerHeight)];
    _pickerView.delegate = self;
    _pickerView.dataSource = self;
    _pickerView.showsSelectionIndicator = YES;
    _pickerView.backgroundColor = [UIColor colorWithRed:0.8 green:0.9 blue:0.5 alpha:1];
    [self.view addSubview:_pickerView];
}


- (void)fliterEvent:(NSString *)filterName
{
    if ([filterName isEqualToString:@"OriginImage"]) {
        _imageView.image = _originImage;
    } else {
        CIImage *ciImage = [CIImage alloc] init
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
